﻿#region Using Directives

    using System.Collections.Generic;
    using System.Web.UI.HtmlControls;

#endregion

namespace MarketPulse.Web.Helpers.Legacy
{
    /// <summary>
    /// Class used to provide helper functions for the creation of Html controls
    /// </summary>
    public static class HtmlControlHelper
    {
        #region Constants

            #region Control Types

                /// <summary>Div html control</summary>
                public const string DIV = "div";

                /// <summary>BR html control</summary>
                public const string BR = "br";

                /// <summary>H2 html control</summary>
                public const string H2 = "h2";

                /// <summary>Table html control</summary>
                public const string TABLE = "table";

                /// <summary>TH html control</summary>
                public const string TH = "th";

                /// <summary>TR html control</summary>
                public const string TR = "tr";

                /// <summary>TD html control</summary>
                public const string TD = "td";

                /// <summary>Image html control</summary>
                public const string IMAGE = "image";

                /// <summary>A html control</summary>
                public const string A = "a";

                /// <summary>UL html control</summary>
                public const string UL = "ul";

                /// <summary>LI html control</summary>
                public const string LI = "li";

            #endregion

            #region Control Attributes

                /// <summary>ID html control attribute</summary>
                public const string ID = "id";

                /// <summary>Class html control attribute</summary>
                public const string CLASS = "class";

                /// <summary>Alt html control attribute</summary>
                public const string ALT = "alt";

                /// <summary>Source (src) html control attribute</summary>
                public const string SRC = "src";

                /// <summary>Height html control attribute</summary>
                public const string HEIGHT = "height";

                /// <summary>Href html control attribute</summary>
                public const string HREF = "href";

            #endregion

        #endregion

        #region Methods

            /// <summary>
            /// Method used to assist in the construction of a generic Html control 
            /// </summary>
            /// <param name="type">The type of control to add</param>
            /// <param name="attributes">A dictionary of attributes to add to the control (key value pairs)</param>
            /// <returns>A valid (filled) generic html control</returns>
            public static HtmlGenericControl AddGenericHtmlControl(string type, Dictionary<string, string> attributes)
            {
                // Instantiate the return object
                HtmlGenericControl temporaryHtmlControl = new HtmlGenericControl(type);

                // Iterate over the attributes supplied and add them to the control
                foreach (KeyValuePair<string, string> attributeKeyValuePair in attributes)
                {
                    temporaryHtmlControl.Attributes.Add(attributeKeyValuePair.Key, attributeKeyValuePair.Value);
                }
                return temporaryHtmlControl;
            }

        #endregion
    }      
}
